package bookworm;

import java.util.LinkedList;

/**
 * this class will contain all books from one author, all books from one author and a specific tag
 * and an average rating that indicates how good is the author for writing books from the specified
 * tag.
 * @author Mina
 *
 */
public class BooksAndRatingOfOneAuthor 
{
	private LinkedList<Book> allBooksFromAuthor;
	private LinkedList<Book> booksFromAuthorRelatedToTag;
	private String tag;
	private String author;
	private int averageRatingOfAuthorBasedOnTag;
	
	public BooksAndRatingOfOneAuthor(LinkedList<Book> booksFromAuthor,
			int averageRatingOfAuthor, String tag, String author, LinkedList<Book> booksRelatedToTag)
	{
		this.allBooksFromAuthor = booksFromAuthor;
		this.booksFromAuthorRelatedToTag = booksRelatedToTag;
		this.tag = tag;
		this.author = author;
		this.averageRatingOfAuthorBasedOnTag = averageRatingOfAuthor;
	}

	public LinkedList<Book> getAllBooksFromAuthor() 
	{
		return allBooksFromAuthor;
	}

	public int getAverageRatingOfAuthorBasedOnTag() {
		return averageRatingOfAuthorBasedOnTag;
	}

	public LinkedList<Book> getBooksFromAuthorRelatedToTag() 
	{
		return booksFromAuthorRelatedToTag;
	}


	public String getTag() {
		return tag;
	}
	
	public String getAuthor()
	{
		return author;
	}
	
	public int howManyBookReviewsWereUsedToCalculateAverageRatingOfAuthor()
	{
		/*for every book, we'll get how many reviews are there from this book and
		  sum the number of reviews from all books
		*/
		int howManyReviewsWereUsed = 0;
		for(int i = 0; i < this.booksFromAuthorRelatedToTag.size(); i++)
		{
			Book oneBook = this.booksFromAuthorRelatedToTag.get(i);
			int howManyReviewsFromOneBook = oneBook.getNumberOfReviewsFromBook();
			howManyReviewsWereUsed = howManyReviewsWereUsed + howManyReviewsFromOneBook;
		}
		return howManyReviewsWereUsed;
	}

}
